Class Path

java.lang.Object
edu.uky.ai.path.Location
edu.uky.ai.path.Path

public class Path
extends Location
A path is a sequence of Locations that is defined by the last location on the path.
Author:
Stephen G. Ware
  • Field Summary

    Fields 
    Modifier and Type Field Description
    int length
    The lengt of this path
    Path rest
    All the locations before this location in the path (or null)

    Fields inherited from class edu.uky.ai.path.Location

    map, solid, x, y
  • Constructor Summary

    Constructors 
    Constructor Description
    Path​(Location first)
    Constructs a path with only a single given location.
  • Method Summary

    Modifier and Type Method Description
    Path addToPath​(Location last)
    Returns a new path with the given location added to the end.
    boolean contains​(Location location)
    Tests whether or not this path contains the given location.
    java.lang.String toString()  

    Methods inherited from class edu.uky.ai.path.Location

    equals, getX, getY, hashCode, neighbors

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • rest

      public final Path rest
      All the locations before this location in the path (or null)
    • length

      public final int length
      The lengt of this path
  • Constructor Details

    • Path

      public Path​(Location first)
      Constructs a path with only a single given location.
      Parameters:
      first - the first location on the path
  • Method Details

    • toString

      public java.lang.String toString()
      Overrides:
      toString in class Location
    • contains

      public boolean contains​(Location location)
      Tests whether or not this path contains the given location.
      Parameters:
      location - the location to test
      Returns:
      true if this location is part of this path, false otherwise
    • addToPath

      public Path addToPath​(Location last)
      Returns a new path with the given location added to the end.
      Parameters:
      last - the location to add to the end of the new path
      Returns:
      a new path with the given location added to the end